package com.neusoft.demo2;

import java.util.Scanner;

/**
 * 方法练习
 * 1. 用户注册功能 insert into user(bianhao, name, mima, school, gender) values(1,fender,‘111111’,neu,'')
 * 2. 用户登录功能 select * from user where username=? and password=?
 * 3. 根据编号查询某个用户信息 select * from student where sid=?
 * 4. 根据编号删除某个用户 delete from student where sid=?
 * 5. 查询所有用户信息 select * from student
 * 只需要将方法出来就可以
 *
 */
public class MethodDemo2 {
    /**
     * 注册
     * @param username
     * @param password
     * @param school
     * @param sex
     * @return
     */
    public static boolean register(String username,String password,String school,int sex){
        //        System.out.println(username);
        return true;
    }

    /**
     * 登录
     * @param username 用户名
     * @param password 密码
     * @return
     */
    public static boolean login(String username,String password) {
        return true;
    }

    /**
     * 根据编号查询某个人的信息
     * @param sid
     * @return
     */
    public static String queryById(int sid) {
        return "用户的编号+姓名+密码+年龄+所在学校";
    }

    /**
     * 根据id删除某个人
     * @param sid
     * @return
     */
    public static int deleteById(int sid) {
        return 0;
    }

    public static String[] selectAll() {
        String[] arr = {"fender","xxxxx","yyyyy"};
        //int a = 1;
        return arr;
    }

    public static void main(String[] args) {
        String[] z = selectAll();
        for(int i = 0;i<z.length;i++) {
            System.out.println(z[i]);
        }
        for (String s :z) { //增强for循环
            System.out.println(s);
        }
        System.out.println("------------------------------------------------");
        int y = deleteById(100);
        if(y == 1) {
            System.out.println("删除成功......");
        }else {
            System.out.println("删除失败......");
        }

        String res = queryById(100);
        System.out.println(res);

        boolean result = register("fender","111111","neu",1);
        if(result) {
            System.out.println("注册成功......");
        }else {
            System.out.println("注册失败......");
        }

        boolean isRight = login("fender","123456");
        if(isRight) {
            System.out.println("登录成功......");
        }else {
            System.out.println("登录失败......");
        }
    }
}
